<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=0,user-scalable=0">
[#include "/wap/include/static.html"]
    <link rel="stylesheet" href="${path}/resources/wap/css/logIn/findpsd.css"/>
</head>
<body>
<!--头部-->
<header>
    <div class="left">
        <img id="goBack" src="${path}/resources/wap/img/me/blank.png">
    </div>
    <div class="center">
        找回密码
    </div>
</header>
<!--输入框-->
<form class="layui-form">
<div id="matter">
    <div class="matter-option">
        <input name="type" type="hidden" value="${type}"  placeholder="请输入你的手机号">
        <label class="tel" for="tel"><img src="${path}/resources/wap/img/logIn/tel.png" alt="图片"/></label><input name="mobile" value="${mobile}" [#if mobile??]readonly[/#if]  id="mobile" placeholder="请输入你的手机号">
    </div>
    <div class="matter-option">
        <label class="qr" for="qr"><img class="img" src="${path}/resources/wap/img/logIn/qr.png" alt="图片"/></label><input id="captcha" name="captcha" placeholder="验证码"> <img src="${path}/common/random" class="qrimg"
                                                                                                                                                                              onclick="this.src = '${path}/common/random?' + Math.random();"
                                                                                                                                                                              title="点击刷新验证码"/>
    </div>
    <div class="matter-option">
        <label  class="telqr" for="telqr"><img src="${path}/resources/wap/img/logIn/telqr.png" alt="图片"/></label><input id="telqr" name="code" placeholder="手机验证码"><div class="get-qr">获取验证码</div>
    </div>

    <div class="matter-option">
        <label class="psd" for="psd"><img src="${path}/resources/wap/img/logIn/psd.png" alt="图片"/></label><input id="psd"name="pass1"  type="password" placeholder="请输入新密码：6-12位字母和数字">
    </div>
    <div class="matter-option">
        <label class="psd2" for="psd2"><img src="${path}/resources/wap/img/logIn/psd.png" alt="图片"/></label><input id="psd2" name="pass2" type="password" placeholder="请确认新密码：6-12位字母和数字">
    </div>

</div>
<!--按钮-->
<div class="button" id="change"  lay-submit lay-filter="MainForm">
    修改密码
</div>
</form>
<div class="alert" style="display: none">
    <div class="content">
        <div class="content-top">提醒</div>
        <div class="content-center">你已经修改成功，自动为你跳转</div>
        <div class="content-next" id="roger">我知道了</div>
    </div>
</div>

</body>
<script>

    layui.use(['form','layer'], function(){
        var form = layui.form(), $=layui.jquery, layer = layui.layer;
        form.on('submit(MainForm)', function(data){

                var index = layer.load();
                ajax({
                    url:"${path}/wap/password/modify",
                    data: data.field,
                    success: function(result){
                        if (result.type == "success") {
                            $("#roger").click();
                        } else {
                            layer.msg(result.content,{icon:2});
                        }
                        layer.close(index);
                    },
                    complete:function(){
                        layer.close(index);
                    },error:function(){
                        layer.closeAll();
                    }
                });

            return false;
        });
    });

    $(function () {
        $(".get-qr").on("click",function () {
            var captcha = $("#captcha").val();
            var mobilePhone = $("#mobile").val();


            if (captcha == '') {
                alert("请输入图形验证码");
                return false;
            }

            $(".get-qr").attr("disabled", "disabled").css("background-color",
                    "#D0CCC9");
            ajax({
                type : "post",
                url : "${path }/wap/send",
                data : {
                    "captcha" : captcha,
                    "mobile" : mobilePhone
                },
                dataType : "json",
                success : function(result) {
                    if (result.type == "success"){
                        $(".get-qr").attr("disabled", "disabled").css(
                                "background-color", "#D0CCC9");
                        var s = 60;
                        $(".get-qr").text(s + "秒");
                        inter = setInterval(function() {
                            s--;
                            $(".get-qr").text(s + "秒");
                            if (s == 0) {
                                $(".get-qr").removeAttr("disabled").css("background-color", "#2188f6").text("免费获取");
                                $(".qrimg").attr("src", '${path }/common/random?rd=' + Math.random());
                                clearInterval(inter);
                            }
                        }, 1000);
                    }else{
                        alert(result.content);
                        $(".get-qr").removeAttr("disabled").css(
                                "background-color", "#2188f6").text(
                                "免费获取");
                        $(".qrimg").click();
                    }

                }
            });
        });




        $("#roger").on("click",function () {
            if(${type}=='deal')
            {
                window.location.href = "${path}/wap/member";
            }
            if(${type}=='safe')
            {
                window.location.href = "${path}/logout";
            }
        });

    });


</script>

</html>